package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.common.constans.ArticleConstants;
import com.heima.model.article.dto.ArticleDto;
import com.heima.model.article.dto.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 文章信息表，存储已发布的文章 前端控制器
 * </p>
 *
 * @author wyq
 */
@Slf4j
@RestController
@RequestMapping("api/v1/article")
public class ApArticleController {

    @Autowired
    private ApArticleService  apArticleService;

    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto articleHomeDto){


        ResponseResult result= apArticleService.loadInit(articleHomeDto, ArticleConstants.LOADTYPE_LOAD_MORE);

        return result;
    }

    @PostMapping("loadmore")
    public ResponseResult loadmore(@RequestBody ArticleHomeDto articleHomeDto){


        ResponseResult result= apArticleService.loadInit(articleHomeDto,ArticleConstants.LOADTYPE_LOAD_MORE);

        return result;
    }

    @PostMapping("loadnew")
    public ResponseResult loadnew(@RequestBody ArticleHomeDto articleHomeDto){


        ResponseResult result= apArticleService.loadInit(articleHomeDto,ArticleConstants.LOADTYPE_LOAD_NEW);
        return result;
    }


}
